{% extends "base.html" %}
{% block title %}排行榜查询提交系统{% endblock %}

{% block head %}
{{ super() }}
<link rel="stylesheet" href="/static/layui/css/layui.css">
<style>
	.layui-form-label{width: 100px;}
	.layui-form-switch{height: 25px;line-height: 25px;}
  .updatadl{margin-top: 8px;}
</style>
{% endblock %}

{% block content %}
<div class="container">
	<h3 class="text-center">设置</h3>
	<form class="layui-form" action="">
	<div class="layui-form-item">
	    <label class="layui-form-label">代理设置</label>
	    <div class="layui-input-block">
	      <input type="checkbox" {% if isproxy %}checked{% endif %} name="close" lay-skin="switch" lay-filter="switchTest" title="开关" lay-text="ON|OFF">
        <button type="button" class="layui-btn layui-btn-xs updatadl">更新代理</button>
	    </div>     
  	</div>
  </form>
</div>
{% endblock %}


{% block scripts %}
{{ super() }}
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script src="/static/js/common.js"></script>
<script>
layui.use(['form'], function(){
  var form = layui.form
  ,layer = layui.layer

  //监听指定开关
  form.on('switch(switchTest)', function(data){
  	$.post('/setting/', {action: 'proxys',checked:this.checked}, function(data, textStatus, xhr) {
  		console.log(xhr);
  	});
  	if(this.checked){
  		layer.msg("开");
  	}else{
  		layer.msg("关");
  	}
    // layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
    //   offset: '6px'
    // });
    // layer.tips('OFF', data.othis)
  });
  
  
});
$(".updatadl").click(function(event) {
  var index = layer.load(1);
  $.post('/setproxys/', {param1: 'value1'}, function(data, textStatus, xhr) {
    layer.close(index);
    layer.msg("更新成功");
  });
});
</script>
{% endblock %}